package com.iweb.config;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;

/**
 * Time :2022/8/16 11:52
 * Author : kriller
 * Project : steam-malls
 */
@EnableTransactionManagement
@Configuration
@MapperScan("com.iweb.mapper") // mapper 代理接口
public class MyBatisConfig {

    // 注册 事务管理器 到 spring 容器
    @Bean
    public TransactionManager transactionManager(DataSource dataSource) {
        DataSourceTransactionManager
                transactionManager = new DataSourceTransactionManager(dataSource);
        return transactionManager;
    }

}
